<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改文章</title>
    <link rel="stylesheet" href="public/layui/css/layui.css">
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
    <form class="layui-form layui-form-pane layui-padding-3" lay-filter="edit" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-input-inline">
                <input type="text" name="title" autocomplete="off" placeholder="请输入文章标题" lay-verify="required"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入文章内容" class="layui-textarea" name="content"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-verify="required" id="status">
                    <option value="">请选择文章状态</option>
                    <option value="0">待审核</option>
                    <option value="1" selected>正常</option>
                </select>
            </div>
        </div>
        <input type="text" name="id" value="<{$data.id}>" hidden>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit lay-filter="add">修改</button>
        </div>
    </form>
    <script src="./public/layui/layui.js"></script>
    <script>
        layui.use(function () {
            var form = layui.form
            var $ = layui.$
            form.val('edit',{
                title : "<{$data.title}>",
                status : "<{$data.status}>",
                content : "<{$data.content}>",
            })
            form.on('submit(add)', function (data) {
                field = data.field
                $.post('?p=index&c=article&a=doEdit', field, (res) => {
                    if (res.code == 200) {
                        layer.msg('修改成功')
                    } else {
                        layer.msg(res.msg)
                    }
                })
                return false
            })
        })
    </script>
</body>

</html>